package com.tiza.xiaoyoubao.ui.fragment;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.TextView;

import com.tianze.library.base.BaseFragment;
import com.tiza.xiaoyoubao.R;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mapple on 17/3/1.
 * <p>
 * 浏览任务未完成
 */

public class BrowseUnComplateFragment extends BaseFragment  {

    @BindView(R.id.tv_sort1)
    TextView tv_sort1;
    @BindView(R.id.tv_sort2)
    TextView tv_sort2;
    //@BindView(R.id.tv_sort3)
    //TextView tv_sort3;
    @BindView(R.id.tv_selectline1)
    TextView tv_selectline1;
    @BindView(R.id.tv_selectline2)
    TextView tv_selectline2;
    //@BindView(R.id.tv_selectline3)
    //TextView tv_selectline3;
    private static FragmentManager fm ;
    @Override
    protected int getLayoutId() {
        return R.layout.fragment_browse_uncomplate;
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void initView() {
        fm=getFragmentManager();
        showFragment(new BrowseOperateFragment());
        tv_sort1.setTextColor(getResources().getColor(R.color.steel_blue));
        tv_selectline1.setVisibility(View.VISIBLE);
        tv_selectline1.setBackgroundColor(getResources().getColor(R.color.steel_blue));
    }

    public void resetTabsStatus(){
        tv_sort1.setTextColor(getResources().getColor(R.color.black));
        tv_sort2.setTextColor(getResources().getColor(R.color.black));
        //tv_sort3.setTextColor(getResources().getColor(R.color.black));
        tv_selectline1.setVisibility(View.INVISIBLE);
        tv_selectline2.setVisibility(View.INVISIBLE);
        //tv_selectline3.setVisibility(View.INVISIBLE);
        tv_selectline1.setBackgroundColor(getResources().getColor(R.color.black));
        tv_selectline2.setBackgroundColor(getResources().getColor(R.color.black));
        //tv_selectline3.setBackgroundColor(getResources().getColor(R.color.black));
    }
    @OnClick({R.id.view_sort1, R.id.view_sort2/*, R.id.view_sort3*/})
    public void onClick(View view) {
        resetTabsStatus();
        switch (view.getId()) {
            case R.id.view_sort1:
                tv_sort1.setTextColor(getResources().getColor(R.color.steel_blue));
                tv_selectline1.setVisibility(View.VISIBLE);
                tv_selectline1.setBackgroundColor(getResources().getColor(R.color.steel_blue));
                showFragment(new BrowseOperateFragment());
                break;
            case R.id.view_sort2:
                tv_sort2.setTextColor(getResources().getColor(R.color.steel_blue));
                tv_selectline2.setVisibility(View.VISIBLE);
                tv_selectline2.setBackgroundColor(getResources().getColor(R.color.steel_blue));
                showFragment(new BrowseConfirmFragment());
                break;
            //case R.id.view_sort3:
                //tv_sort3.setTextColor(getResources().getColor(R.color.steel_blue));
                //tv_selectline3.setVisibility(View.VISIBLE);
                //tv_selectline3.setBackgroundColor(getResources().getColor(R.color.steel_blue));
                //showFragment(new BrowseAllFragment());
                //break;
            default:
                break;
        }
    }

    public static void showFragment(Fragment fragment) {
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.fl_content, fragment);
        transaction.commit();

    }
}
